/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package umled.view;

import javax.swing.*;
import java.awt.*;
import java.util.Observer;
import java.util.Observable;
import umled.model.*;
/**
 *
 * @author ANor
 */
public class UMLPanel extends JPanel implements Observer {
    private UMLModel model;
    public UMLPanel( UMLModel model ){
        model.addObserver( this );
        this.model = model;
        repaint();
    }
    
    @Override
    public void paintComponent(Graphics g){
        Graphics2D g2d = (Graphics2D) g;
        model.draw(g2d, getWidth(), getHeight());
    }
    public void update( Observable observable , Object obj){
        if(observable instanceof UMLElement){
            UMLElement element = (UMLElement) observable;
            element.draw( (Graphics2D) getGraphics(),
                element.getParent().getWidth(), element.getParent().getHeight());
        }
    }
}


